home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / cloak.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  11KB  |  387 lines

  1. /****************************************************************************
  2.  
  3. Master processor
  4.  
  5. IRQ: 4 IRQ's per frame at even intervals, 4th IRQ is at start of VBLANK
  6.  
  7. 000-3FF       Working RAM
  8. 400-7FF    Playfield RAM
  9. 800-FFF    Communication RAM (shared with slave processor)
  10.  
  11. 1000-100F  Pokey 1
  12. 1008 (R)   bit 7 = Start 2 players
  13.           bit 6 = Start 1 player
  14.  
  15. 1800-180F  Pokey 2
  16. 1808(R)       Dipswitches
  17.  
  18. 2000 (R):  Joysticks
  19. 2200 (R):  Player 2 joysticks (for cocktail version)
  20.  
  21. 2400 (R)   bit 0: Vertical Blank
  22.        bit 1: Self test switch
  23.        bit 2: Left Coin
  24.        bit 3: Right Coin
  25.        bit 4: Cocktail mode
  26.        bit 5: Aux Coin
  27.        bit 6: Player 2 Igniter button
  28.        bit 7: Player 1 Igniter button
  29.  
  30. 2600 (W) Custom Write (this has something to do with positioning of the display out, I ignore it)
  31.  
  32. 2800-29FF: (R/W) non-volatile RAM
  33. 3000-30FF: (R/W) Motion RAM
  34. 3200-327F: (W) Color RAM, Address bit 6 becomes the 9th bit of color RAM
  35.  
  36. 3800: (W) Right Coin Counter
  37. 3801: (W) Left Coint Counter
  38. 3803: (W) Cocktail Output
  39. 3806: (W) Start 2 LED
  40. 3807: (W) Start 1 LED
  41.  
  42. 3A00: (W) Watchdog reset
  43. 3C00: (W) Reset IRQ
  44. 3E00: (W) bit 0: Enable NVRAM
  45.  
  46. 4000 - FFFF ROM
  47.     4000-5FFF  136023.501
  48.     6000-7FFF  136023.502
  49.     8000-BFFF  136023.503
  50.     C000-FFFF  136023.504
  51.  
  52.  
  53. Slave processor
  54.  
  55. IRQ: 1 IRQ per frame at start of VBLANK
  56.  
  57. 0000-0007: Working RAM
  58. 0008-000A, 000C-000E: (R/W) bit 0,1,2: Store to/Read From Bit Map RAM
  59.  
  60. 0008: Decrement X/Increment Y
  61. 0009: Decrement Y
  62. 000A: Decrement X
  63. 000B: Set bitmap X coordinate
  64. 000C: Increment X/Increment Y  <-- Yes this is correct
  65. 000D: Increment Y
  66. 000E: Increment X
  67. 000F: Set bitmap Y coordinate
  68.  
  69. 0010-07FF: Working RAM
  70. 0800-0FFF: Communication RAM (shared with master processor)
  71.  
  72. 1000 (W): Reset IRQ
  73. 1200 (W):  bit 0: Swap bit maps
  74.        bit 1: Clear bit map
  75. 1400 (W): Custom Write (this has something to do with positioning of the display out, I ignore it)
  76.  
  77. 2000-FFFF: Program ROM
  78.     2000-3FFF: 136023.509
  79.     4000-5FFF: 136023.510
  80.     6000-7FFF: 136023.511
  81.     8000-9FFF: 136023.512
  82.     A000-BFFF: 136023.513
  83.     C000-DFFF: 136023.514
  84.     E000-EFFF: 136023.515
  85.  
  86.  
  87. Motion object ROM: 136023.307,136023.308
  88. Playfield ROM: 136023.306,136023.305
  89.  
  90. ****************************************************************************/
  91.  
  92. #include "driver.h"
  93. #include "vidhrdw/generic.h"
  94.  
  95. extern unsigned char *enable_nvRAM;
  96. extern unsigned char *cloak_sharedram;
  97. READ_HANDLER( cloak_sharedram_r );
  98. WRITE_HANDLER( cloak_sharedram_w );
  99. WRITE_HANDLER( cloak_paletteram_w );
  100. READ_HANDLER( graph_processor_r );
  101. WRITE_HANDLER( graph_processor_w );
  102. WRITE_HANDLER( cloak_clearbmp_w );
  103. extern int  cloak_vh_start(void);
  104. extern void cloak_vh_stop(void);
  105. extern void cloak_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  106.  
  107.  
  108. static unsigned char *nvram;
  109. static size_t nvram_size;
  110.  
  111. static void nvram_handler(void *file, int read_or_write)
  112. {
  113.     if (read_or_write)
  114.         osd_fwrite(file,nvram,nvram_size);
  115.     else
  116.     {
  117.         if (file)
  118.             osd_fread(file,nvram,nvram_size);
  119.         else
  120.             memset(nvram,0,nvram_size);
  121.     }
  122. }
  123.  
  124.  
  125. WRITE_HANDLER( cloak_led_w )
  126. {
  127.     osd_led_w(1 - offset,~data >> 7);
  128. }
  129.  
  130.  
  131.  
  132. static struct MemoryReadAddress readmem[] =
  133. {
  134.     { 0x0000, 0x07ff, MRA_RAM },
  135.     { 0x0800, 0x0fff, cloak_sharedram_r },
  136.     { 0x2800, 0x29ff, MRA_RAM },
  137.     { 0x1000, 0x100f, pokey1_r },        /* DSW0 also */
  138.     { 0x1800, 0x180f, pokey2_r },        /* DSW1 also */
  139.     { 0x2000, 0x2000, input_port_0_r },    /* IN0 */
  140.     { 0x2200, 0x2200, input_port_1_r },    /* IN1 */
  141.     { 0x2400, 0x2400, input_port_2_r },    /* IN2 */
  142.     { 0x3000, 0x30ff, MRA_RAM },
  143.     { 0x3800, 0x3807, MRA_RAM },
  144.     { 0x4000, 0xffff, MRA_ROM },
  145.     { -1 }    /* end of table */
  146. };
  147.  
  148. static struct MemoryWriteAddress writemem[] =
  149. {
  150.     { 0x0000, 0x03ff, MWA_RAM },
  151.     { 0x0400, 0x07ff, videoram_w, &videoram, &videoram_size },
  152.     { 0x0800, 0x0fff, cloak_sharedram_w, &cloak_sharedram },
  153.     { 0x1000, 0x100f, pokey1_w },
  154.     { 0x1800, 0x180f, pokey2_w },
  155.     { 0x2800, 0x29ff, MWA_RAM, &nvram, &nvram_size },
  156.     { 0x3000, 0x30ff, MWA_RAM, &spriteram, &spriteram_size },
  157.     { 0x3200, 0x327f, cloak_paletteram_w },
  158.     { 0x3800, 0x3801, coin_counter_w },
  159.     { 0x3802, 0x3805, MWA_RAM },
  160.     { 0x3806, 0x3807, cloak_led_w },
  161.     { 0x3a00, 0x3a00, watchdog_reset_w },
  162.     { 0x3e00, 0x3e00, MWA_RAM, &enable_nvRAM },
  163.     { 0x4000, 0xffff, MWA_ROM },
  164.     { -1 }    /* end of table */
  165. };
  166.  
  167. static struct MemoryReadAddress readmem2[] =
  168. {
  169.     { 0x0000, 0x0007, MRA_RAM },
  170.     { 0x0008, 0x000f, graph_processor_r },
  171.     { 0x0010, 0x07ff, MRA_RAM },
  172.     { 0x0800, 0x0fff, cloak_sharedram_r },
  173.     { 0x2000, 0xffff, MRA_ROM },
  174.     { -1 }    /* end of table */
  175. };
  176.  
  177. static struct MemoryWriteAddress writemem2[] =
  178. {
  179.     { 0x0000, 0x0007, MWA_RAM },
  180.     { 0x0008, 0x000f, graph_processor_w },
  181.     { 0x0010, 0x07ff, MWA_RAM },
  182.     { 0x0800, 0x0fff, cloak_sharedram_w },
  183.     { 0x1200, 0x1200, cloak_clearbmp_w },
  184.     { 0x2000, 0xffff, MWA_ROM },
  185.     { -1 }    /* end of table */
  186. };
  187.  
  188. INPUT_PORTS_START( cloak )
  189.     PORT_START    /* IN0 */
  190.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_DOWN  | IPF_8WAY )
  191.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_UP    | IPF_8WAY )
  192.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_RIGHT | IPF_8WAY )
  193.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_LEFT  | IPF_8WAY )
  194.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_DOWN   | IPF_8WAY )
  195.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_UP     | IPF_8WAY )
  196.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_RIGHT  | IPF_8WAY )
  197.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_LEFT   | IPF_8WAY )
  198.  
  199.     PORT_START    /* IN1 */
  200.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_DOWN  | IPF_8WAY | IPF_COCKTAIL )
  201.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_UP    | IPF_8WAY | IPF_COCKTAIL )
  202.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_RIGHT | IPF_8WAY | IPF_COCKTAIL )
  203.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_LEFT  | IPF_8WAY | IPF_COCKTAIL )
  204.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_DOWN   | IPF_8WAY | IPF_COCKTAIL )
  205.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_UP     | IPF_8WAY | IPF_COCKTAIL )
  206.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_RIGHT  | IPF_8WAY | IPF_COCKTAIL )
  207.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_LEFT   | IPF_8WAY | IPF_COCKTAIL )
  208.  
  209.     PORT_START    /* IN2 */
  210.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_VBLANK )
  211.     PORT_SERVICE( 0x02, IP_ACTIVE_LOW )
  212.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 )
  213.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN1 )
  214.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Cabinet ) )
  215.     PORT_DIPSETTING(    0x10, DEF_STR( Upright ) )
  216.     PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
  217.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 )
  218.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 )
  219.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
  220.  
  221.     PORT_START    /* DSW0 */
  222.     PORT_BIT( 0x3f, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  223.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
  224.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START1 )
  225.  
  226.     PORT_START      /* DSW1 */
  227.     PORT_DIPNAME( 0x03, 0x02, "Credits" )
  228.     PORT_DIPSETTING(    0x02, "*1" )
  229.     PORT_DIPSETTING(    0x01, "*2" )
  230.     PORT_DIPSETTING(    0x03, "/2" )
  231.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  232.     PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coin_B ) )
  233.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  234.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
  235.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_5C ) )
  236.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_6C ) )
  237.     PORT_DIPNAME( 0x10, 0x00, DEF_STR( Coin_A ) )
  238.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  239.     PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) )
  240.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
  241.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  242.     PORT_DIPSETTING(    0x20, DEF_STR( On ) )
  243.     PORT_DIPNAME( 0x40, 0x00, "Allow Freeze" )    /* when active, press button 1 to freeze */
  244.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  245.     PORT_DIPSETTING(    0x40, DEF_STR( On ) )
  246.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
  247.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  248.     PORT_DIPSETTING(    0x80, DEF_STR( On ) )
  249.  
  250. INPUT_PORTS_END
  251.  
  252.  
  253. static struct GfxLayout charlayout =
  254. {
  255.     8,8,    /* 8*8 characters */
  256.     256,    /* 512 characters */
  257.     4,      /* 4 bits per pixel */
  258.     { 0, 1, 2, 3 }, /* the bitplanes are packed in one nibble */
  259.     { 0x1000*8+0, 0x1000*8+4, 0, 4, 0x1000*8+8, 0x1000*8+12, 8, 12 },
  260.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
  261.     16*8   /* every char takes 16 consecutive bytes */
  262. };
  263.  
  264. static struct GfxLayout spritelayout =
  265. {
  266.     8,16,   /* 8*16 sprites */
  267.     128,    /* 128 sprites  */
  268.     4,      /* 4 bits per pixel */
  269.     { 0, 1, 2, 3 }, /* the bitplanes are packed in one nibble */
  270.     { 0x1000*8+0, 0x1000*8+4, 0, 4, 0x1000*8+8, 0x1000*8+12, 8, 12 },
  271.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
  272.         8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
  273.     16*16   /* every char takes 32 consecutive bytes */
  274. };
  275.  
  276. static struct GfxDecodeInfo gfxdecodeinfo[] =
  277. {
  278.     { REGION_GFX1, 0, &charlayout,     0,  1 },
  279.     { REGION_GFX2, 0, &spritelayout,  32,  1 },
  280.     { -1 }
  281. };
  282.  
  283.  
  284.  
  285. static struct POKEYinterface pokey_interface =
  286. {
  287.     2,    /* 2 chips */
  288.     1500000,    /* 1.5 MHz??? */
  289.     { 50, 50 },
  290.     /* The 8 pot handlers */
  291.     { 0, 0 },
  292.     { 0, 0 },
  293.     { 0, 0 },
  294.     { 0, 0 },
  295.     { 0, 0 },
  296.     { 0, 0 },
  297.     { 0, 0 },
  298.     { 0, 0 },
  299.     /* The allpot handler */
  300.     { input_port_3_r, input_port_4_r }
  301. };
  302.  
  303.  
  304.  
  305. static struct MachineDriver machine_driver_cloak =
  306. {
  307.     /* basic machine hardware */
  308.     {
  309.         {
  310.             CPU_M6502,
  311.             1000000,    /* 1 Mhz ???? */
  312.             readmem,writemem,0,0,
  313.             interrupt,4
  314.         },
  315.         {
  316.             CPU_M6502,
  317.             1250000,        /* 1 Mhz ???? */
  318.             readmem2,writemem2,0,0,
  319.             interrupt,2
  320.         }
  321.     },
  322.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  323.     5,
  324.     0,
  325.  
  326.     /* video hardware */
  327.     32*8, 32*8, { 0*8, 32*8-1, 3*8, 32*8-1 },
  328.     gfxdecodeinfo,
  329.     64, 64,
  330.     0,
  331.  
  332.  
  333.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_SUPPORTS_DIRTY,
  334.     0,
  335.     cloak_vh_start,
  336.     cloak_vh_stop,
  337.     cloak_vh_screenrefresh,
  338.  
  339.     /* sound hardware */
  340.     0,0,0,0,
  341.     {
  342.         {
  343.             SOUND_POKEY,
  344.             &pokey_interface
  345.         }
  346.     },
  347.  
  348.     nvram_handler
  349. };
  350.  
  351.  
  352.  
  353. /***************************************************************************
  354.  
  355.   Game driver(s)
  356.  
  357. ***************************************************************************/
  358.  
  359. ROM_START( cloak )
  360.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for code */
  361.     ROM_LOAD( "136023.501",   0x4000, 0x2000, 0xc2dbef1b )
  362.     ROM_LOAD( "136023.502",   0x6000, 0x2000, 0x316d0c7b )
  363.     ROM_LOAD( "136023.503",   0x8000, 0x4000, 0xb9c291a6 )
  364.     ROM_LOAD( "136023.504",   0xc000, 0x4000, 0xd014a1c0 )
  365.  
  366.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for code */
  367.     ROM_LOAD( "136023.509",   0x2000, 0x2000, 0x46c021a4 )
  368.     ROM_LOAD( "136023.510",   0x4000, 0x2000, 0x8c9cf017 )
  369.     ROM_LOAD( "136023.511",   0x6000, 0x2000, 0x66fd8a34 )
  370.     ROM_LOAD( "136023.512",   0x8000, 0x2000, 0x48c8079e )
  371.     ROM_LOAD( "136023.513",   0xa000, 0x2000, 0x13f1cbab )
  372.     ROM_LOAD( "136023.514",   0xc000, 0x2000, 0x6f8c7991 )
  373.     ROM_LOAD( "136023.515",   0xe000, 0x2000, 0x835438a0 )
  374.  
  375.     ROM_REGION( 0x2000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  376.     ROM_LOAD( "136023.305",   0x0000, 0x1000, 0xee443909 )
  377.     ROM_LOAD( "136023.306",   0x1000, 0x1000, 0xd708b132 )
  378.  
  379.     ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  380.     ROM_LOAD( "136023.307",   0x0000, 0x1000, 0xc42c84a4 )
  381.     ROM_LOAD( "136023.308",   0x1000, 0x1000, 0x4fe13d58 )
  382. ROM_END
  383.  
  384.  
  385.  
  386. GAMEX( 1983, cloak, 0, cloak, cloak, 0, ROT0, "Atari", "Cloak & Dagger", GAME_NO_COCKTAIL )
  387.